<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>煤炭管理系统</title>
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/layui/css/layui-theme-custom.css">
    <link rel="stylesheet" href="/static/css/member.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <#include "/base/main-header.ftl">

    <#include "/base/main-left.ftl">
    <div class="layui-body">
        <#include "../purchaseRequisitions/template/Purchasing-info.ftl">
        <#include "../purchaseRequisitions/template/coal-quality.ftl">

        <div class="site-title">
            <fieldset>
                <legend>
                    <a class="site-title-text">供应商报价</a>
                </legend>
            </fieldset>
        </div>
        <div class="table-box">
            <form  class="layui-form">
                <table class="layui-table" >
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>供应商名称</th>
                            <th>热值</th>
                            <th>供应数量（万/吨）</th>
                            <th>本次报价</th>
                            <th>供应折卡煤价（元/卡.吨）</th>
                            <th>合同数量（万/吨）</th>
                            <th>合同单价（元/吨）</th>
                            <th>合同折卡煤价（元/卡.吨）</th>
                            <th>运费</th>
                            <th>产地</th>
                            <th>发站(发货港口)</th>
                            <th>空干基全硫</th>
                            <th>收到基挥发分</th>
                            <th>空干基灰分</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list suppliers as s>
                            <tr>
                                <input type="hidden" value="${s.id!""}" name="id[]">
                                <input type="hidden" value="${s.execId!""}" name="execId[]">
                                <td>${s.id!""}</td>
                                <td>${s.name!""}</td>
                                <td>${s.heat!""}</td>
                                <td>${s.getSNum()!""}</td>
                                <td>${s.quote!""}</td>
                                <td>${s.SDisPrice!""}</td>
                                <td><input required lay-verify="required" name="contractsNum[]" min="0" style="width: 50px" type="number"></td>
                                <td><input required lay-verify="required" name="contractsPrice[]" min="0" style="width: 50px" type="number"></td>
                                <td>${s.CDisPrice!""}</td>
                                <td>${s.fare!""}</td>
                                <td>${s.produceFrom!""}</td>
                                <td>${s.shippingPort!""}</td>
                                <td>${s.type1!""}</td>
                                <td>${s.type2!""}</td>
                                <td>${s.type3!""}</td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                <div style="text-align:center;margin-top: 20px">
                    <button type="submit" lay-submit lay-filter="savePE" class="layui-btn layui-btn-radius">提交</button>
                    <button class="layui-btn layui-btn-radius layui-btn-primary" onclick="window.location='/queryPE'">返回</button>
                </div>

            </form>
        </div>



    </div>
    <#include "/base/main-footer.ftl">
</div>

<script src="/static/lib/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form', 'element', 'jquery','table'], function () {
        let layer = layui.layer, form = layui.form, $ = layui.$, table=layui.table;
        let loading = false
        let re = new RegExp("(.*)\\[(\\d)\\]");
        form.on('submit(savePE)', function (data) {
            if (loading) {
                return false;
            }
            loading = true
            let temp = []
             Object.keys(data.field).forEach(value => {
                 let group = re.exec(value)
                 let k = group[1],v = data.field[group[0]] ,i = group[2]
                 temp[i] = Object.assign(temp[i]||{},{
                     [k]:v
                 })
             })
            $.ajax({
                type: "POST",
                url: "/purchExec/updatePE.do",
                data: JSON.stringify(temp) ,
                dataType: "json",
                contentType: 'application/json; charset=UTF-8',
                success: function (data) {
                    if (data.isSuccess){
                        layer.msg("创建成功")
                        setTimeout(function () {
                            loading = false
                            window.location = "/queryPE"
                        },2000)
                    } else {
                        loading = false
                        layer.msg(data.msg)
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>